package cn.hnh.controller;

import cn.hnh.service.CategoriesService;
import cn.hnh.vo.ArticleTitleVo;
import cn.hnh.vo.CategoriesVo;
import cn.hnh.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * @Author HuangNianHong
 * @Time 2021/1/5
 */
@RestController
@Api(tags = "博客分类页接口规范描述")
public class CategoriesController {
    @Autowired
    private CategoriesService categoriesService;

    @ApiOperation(value = "查询博客分类信息")
    @RequestMapping("/categories")
    public Result<CategoriesVo> getCategoriesInfo(){
        return categoriesService.getCategoriesVo();
    }

    @ApiOperation(value = "根据分类名称查询对应此分类下所有的文章列表")
    @RequestMapping("/categories/{categoriesName}")
    public Result<List<ArticleTitleVo>> getArticleTitleVoByCategoriesName(@PathVariable("categoriesName")String categoriesName){
        return categoriesService.getArticleTitleVoByCategoriesName(categoriesName);
    }
}
